<?php
// Utilisation de l'encodage UTF-8
header('Content-type: text/html; charset=UTF-8');

// Définition des constantes d'environnement

//-------------------------------------------
if(!defined('APP_DIR'))
    define('APP_DIR','app');
//-------------------------------------------
if(!defined('ROOT_DIR'))
    define('ROOT_DIR',dirname(dirname(__FILE__)));

if(!defined('DS'))
    define('DS', DIRECTORY_SEPARATOR);

if(!defined('PS'))
    define('PS', PATH_SEPARATOR);

if(!defined('REWRITE'))
    define('REWRITE',false);

if(!defined('SERVER')) {
    if($_SERVER['SERVER_NAME'] == 'localhost')
        define('SERVER','dev');
    else
        define('SERVER','prod');
}

// Inclusion de la config générale
require_once(APP_DIR.DS.'config'.DS.'core.php');

// Inclusion des variables d'accés db
require_once('database.php');

//Initialiation du logger
require_once(APP_DIR.DS.'logger.php');
logger::info("Initialisation du logger",__FILE__,__LINE__);

// Initialisation de l'accés db
require_once(APP_DIR.DS.'dbaccess.php');
$bdd = Dbaccess::getInstance('mysql:host='.$database[SERVER]['host'].';dbname='.$database[SERVER]['dbname'],$database[SERVER]['user'],$database[SERVER]['password']);
logger::info("Initilisation de la classe d'accès db",__FILE__,__LINE__);

//Inclusion de la classe de configuration
require_once(APP_DIR.DS.'config.php');

Config::write('debug',0);

//require_once(APP_DIR.DS.'error.php');

// Redéfinition de l'include path
set_include_path(get_include_path().PS.ROOT_DIR.DS.'modules'.DS.PS.ROOT_DIR.DS.'controllers'.DS.PS.ROOT_DIR.DS.'help'.DS.PS.APP_DIR.DS.'controllers'.DS.PS.APP_DIR.DS.'models'.DS.PS.APP_DIR.DS.'help'.DS.PS);
?>